{extend name="template/base" /}
{block name="nav"}{/block}
{block name="style"}
<style>
    ul li{width:200px;padding:5px }
</style>
{/block}
{block name="content"}
<div class="page-container">
    {if(!empty($cache_tag))}
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <div class="skin-minimal">
            <div class='pd-5 mb-10'>
                <div class="check-box">
                    <input type="checkbox" name='tag_all' id="checkbox-all">
                    <label for="checkbox-all">全部</label>
                </div>
            </div>
            <div style="height:80px;width:70%">
                <ul>  
                    {foreach ($cache_tag as $key => $val)}
                    <li class='f-l'>
                        <div class="check-box">
                            <input type="checkbox" class='tag_check' value="{$val.tag}" name='tag[]' id="checkbox-{$val.id}" >
                            <label for="checkbox-{$val.id}">{$val.name|default=''}</label>
                        </div>
                    </li>
                    {/foreach}
                </ul></div>
            <div class="row cl mt-20">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" onclick="return check_form();" value="清理">
                </div>
            </div>
        </div>
    </form>
    {/if}
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        
        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret) {
                ajax_progress(ret);
            }
        });
        
        $('#checkbox-all').click(function(){
            if($(this).is(':checked')){
                $('input[name="tag[]"]').attr('checked','true');
                $('input[name="tag[]"]').parent().addClass('checked');
            }
            else{
                $('input[name="tag[]"]').removeAttr('checked');
                $('input[name="tag[]"]').parent().removeClass('checked');
            }
        });
    });
    function check_form(){
        if($('input[name="tag[]"]:checked').length == 0){
            alert('请选择清除缓存');
            return false;
        }else{
            return true;
        }
    }
</script>
{/block}